/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
"use strict";

// var $protobuf = require("protobufjs/minimal");
import * as $protobuf from "protobufjs/minimal";

// Common aliases
var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;

// Exported root namespace
var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});

$root.WrapperMessage = (function() {

    /**
     * Properties of a WrapperMessage.
     * @exports IWrapperMessage
     * @interface IWrapperMessage
     * @property {WrapperMessage.MessageType} type WrapperMessage type
     * @property {WrapperMessage.IHeartbeat|null} [heartbeat] WrapperMessage heartbeat
     * @property {WrapperMessage.ITextMessage|null} [textmessage] WrapperMessage textmessage
     * @property {WrapperMessage.IIdEntity|null} [idmessage] WrapperMessage idmessage
     */

    /**
     * Constructs a new WrapperMessage.
     * @exports WrapperMessage
     * @classdesc Represents a WrapperMessage.
     * @implements IWrapperMessage
     * @constructor
     * @param {IWrapperMessage=} [properties] Properties to set
     */
    function WrapperMessage(properties) {
        if (properties)
            for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
                if (properties[keys[i]] != null)
                    this[keys[i]] = properties[keys[i]];
    }

    /**
     * WrapperMessage type.
     * @member {WrapperMessage.MessageType} type
     * @memberof WrapperMessage
     * @instance
     */
    WrapperMessage.prototype.type = 0;

    /**
     * WrapperMessage heartbeat.
     * @member {WrapperMessage.IHeartbeat|null|undefined} heartbeat
     * @memberof WrapperMessage
     * @instance
     */
    WrapperMessage.prototype.heartbeat = null;

    /**
     * WrapperMessage textmessage.
     * @member {WrapperMessage.ITextMessage|null|undefined} textmessage
     * @memberof WrapperMessage
     * @instance
     */
    WrapperMessage.prototype.textmessage = null;

    /**
     * WrapperMessage idmessage.
     * @member {WrapperMessage.IIdEntity|null|undefined} idmessage
     * @memberof WrapperMessage
     * @instance
     */
    WrapperMessage.prototype.idmessage = null;

    // OneOf field names bound to virtual getters and setters
    var $oneOfFields;

    // Virtual OneOf for proto3 optional field
    Object.defineProperty(WrapperMessage.prototype, "_heartbeat", {
        get: $util.oneOfGetter($oneOfFields = ["heartbeat"]),
        set: $util.oneOfSetter($oneOfFields)
    });

    // Virtual OneOf for proto3 optional field
    Object.defineProperty(WrapperMessage.prototype, "_textmessage", {
        get: $util.oneOfGetter($oneOfFields = ["textmessage"]),
        set: $util.oneOfSetter($oneOfFields)
    });

    // Virtual OneOf for proto3 optional field
    Object.defineProperty(WrapperMessage.prototype, "_idmessage", {
        get: $util.oneOfGetter($oneOfFields = ["idmessage"]),
        set: $util.oneOfSetter($oneOfFields)
    });

    /**
     * Creates a new WrapperMessage instance using the specified properties.
     * @function create
     * @memberof WrapperMessage
     * @static
     * @param {IWrapperMessage=} [properties] Properties to set
     * @returns {WrapperMessage} WrapperMessage instance
     */
    WrapperMessage.create = function create(properties) {
        return new WrapperMessage(properties);
    };

    /**
     * Encodes the specified WrapperMessage message. Does not implicitly {@link WrapperMessage.verify|verify} messages.
     * @function encode
     * @memberof WrapperMessage
     * @static
     * @param {IWrapperMessage} message WrapperMessage message or plain object to encode
     * @param {$protobuf.Writer} [writer] Writer to encode to
     * @returns {$protobuf.Writer} Writer
     */
    WrapperMessage.encode = function encode(message, writer) {
        if (!writer)
            writer = $Writer.create();
        writer.uint32(/* id 1, wireType 0 =*/8).int32(message.type);
        if (message.heartbeat != null && Object.hasOwnProperty.call(message, "heartbeat"))
            $root.WrapperMessage.Heartbeat.encode(message.heartbeat, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();
        if (message.textmessage != null && Object.hasOwnProperty.call(message, "textmessage"))
            $root.WrapperMessage.TextMessage.encode(message.textmessage, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim();
        if (message.idmessage != null && Object.hasOwnProperty.call(message, "idmessage"))
            $root.WrapperMessage.IdEntity.encode(message.idmessage, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim();
        return writer;
    };

    /**
     * Encodes the specified WrapperMessage message, length delimited. Does not implicitly {@link WrapperMessage.verify|verify} messages.
     * @function encodeDelimited
     * @memberof WrapperMessage
     * @static
     * @param {IWrapperMessage} message WrapperMessage message or plain object to encode
     * @param {$protobuf.Writer} [writer] Writer to encode to
     * @returns {$protobuf.Writer} Writer
     */
    WrapperMessage.encodeDelimited = function encodeDelimited(message, writer) {
        return this.encode(message, writer).ldelim();
    };

    /**
     * Decodes a WrapperMessage message from the specified reader or buffer.
     * @function decode
     * @memberof WrapperMessage
     * @static
     * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
     * @param {number} [length] Message length if known beforehand
     * @returns {WrapperMessage} WrapperMessage
     * @throws {Error} If the payload is not a reader or valid buffer
     * @throws {$protobuf.util.ProtocolError} If required fields are missing
     */
    WrapperMessage.decode = function decode(reader, length) {
        if (!(reader instanceof $Reader))
            reader = $Reader.create(reader);
        var end = length === undefined ? reader.len : reader.pos + length, message = new $root.WrapperMessage();
        while (reader.pos < end) {
            var tag = reader.uint32();
            switch (tag >>> 3) {
            case 1: {
                    message.type = reader.int32();
                    break;
                }
            case 2: {
                    message.heartbeat = $root.WrapperMessage.Heartbeat.decode(reader, reader.uint32());
                    break;
                }
            case 3: {
                    message.textmessage = $root.WrapperMessage.TextMessage.decode(reader, reader.uint32());
                    break;
                }
            case 4: {
                    message.idmessage = $root.WrapperMessage.IdEntity.decode(reader, reader.uint32());
                    break;
                }
            default:
                reader.skipType(tag & 7);
                break;
            }
        }
        if (!message.hasOwnProperty("type"))
            throw $util.ProtocolError("missing required 'type'", { instance: message });
        return message;
    };

    /**
     * Decodes a WrapperMessage message from the specified reader or buffer, length delimited.
     * @function decodeDelimited
     * @memberof WrapperMessage
     * @static
     * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
     * @returns {WrapperMessage} WrapperMessage
     * @throws {Error} If the payload is not a reader or valid buffer
     * @throws {$protobuf.util.ProtocolError} If required fields are missing
     */
    WrapperMessage.decodeDelimited = function decodeDelimited(reader) {
        if (!(reader instanceof $Reader))
            reader = new $Reader(reader);
        return this.decode(reader, reader.uint32());
    };

    /**
     * Verifies a WrapperMessage message.
     * @function verify
     * @memberof WrapperMessage
     * @static
     * @param {Object.<string,*>} message Plain object to verify
     * @returns {string|null} `null` if valid, otherwise the reason why it is not
     */
    WrapperMessage.verify = function verify(message) {
        if (typeof message !== "object" || message === null)
            return "object expected";
        var properties = {};
        switch (message.type) {
        default:
            return "type: enum value expected";
        case 0:
        case 1:
        case 2:
            break;
        }
        if (message.heartbeat != null && message.hasOwnProperty("heartbeat")) {
            properties._heartbeat = 1;
            {
                var error = $root.WrapperMessage.Heartbeat.verify(message.heartbeat);
                if (error)
                    return "heartbeat." + error;
            }
        }
        if (message.textmessage != null && message.hasOwnProperty("textmessage")) {
            properties._textmessage = 1;
            {
                var error = $root.WrapperMessage.TextMessage.verify(message.textmessage);
                if (error)
                    return "textmessage." + error;
            }
        }
        if (message.idmessage != null && message.hasOwnProperty("idmessage")) {
            properties._idmessage = 1;
            {
                var error = $root.WrapperMessage.IdEntity.verify(message.idmessage);
                if (error)
                    return "idmessage." + error;
            }
        }
        return null;
    };

    /**
     * Creates a WrapperMessage message from a plain object. Also converts values to their respective internal types.
     * @function fromObject
     * @memberof WrapperMessage
     * @static
     * @param {Object.<string,*>} object Plain object
     * @returns {WrapperMessage} WrapperMessage
     */
    WrapperMessage.fromObject = function fromObject(object) {
        if (object instanceof $root.WrapperMessage)
            return object;
        var message = new $root.WrapperMessage();
        switch (object.type) {
        default:
            if (typeof object.type === "number") {
                message.type = object.type;
                break;
            }
            break;
        case "HEARTBEAT":
        case 0:
            message.type = 0;
            break;
        case "TEXTMESSAGE":
        case 1:
            message.type = 1;
            break;
        case "IDENTITY":
        case 2:
            message.type = 2;
            break;
        }
        if (object.heartbeat != null) {
            if (typeof object.heartbeat !== "object")
                throw TypeError(".WrapperMessage.heartbeat: object expected");
            message.heartbeat = $root.WrapperMessage.Heartbeat.fromObject(object.heartbeat);
        }
        if (object.textmessage != null) {
            if (typeof object.textmessage !== "object")
                throw TypeError(".WrapperMessage.textmessage: object expected");
            message.textmessage = $root.WrapperMessage.TextMessage.fromObject(object.textmessage);
        }
        if (object.idmessage != null) {
            if (typeof object.idmessage !== "object")
                throw TypeError(".WrapperMessage.idmessage: object expected");
            message.idmessage = $root.WrapperMessage.IdEntity.fromObject(object.idmessage);
        }
        return message;
    };

    /**
     * Creates a plain object from a WrapperMessage message. Also converts values to other types if specified.
     * @function toObject
     * @memberof WrapperMessage
     * @static
     * @param {WrapperMessage} message WrapperMessage
     * @param {$protobuf.IConversionOptions} [options] Conversion options
     * @returns {Object.<string,*>} Plain object
     */
    WrapperMessage.toObject = function toObject(message, options) {
        if (!options)
            options = {};
        var object = {};
        if (options.defaults)
            object.type = options.enums === String ? "HEARTBEAT" : 0;
        if (message.type != null && message.hasOwnProperty("type"))
            object.type = options.enums === String ? $root.WrapperMessage.MessageType[message.type] === undefined ? message.type : $root.WrapperMessage.MessageType[message.type] : message.type;
        if (message.heartbeat != null && message.hasOwnProperty("heartbeat")) {
            object.heartbeat = $root.WrapperMessage.Heartbeat.toObject(message.heartbeat, options);
            if (options.oneofs)
                object._heartbeat = "heartbeat";
        }
        if (message.textmessage != null && message.hasOwnProperty("textmessage")) {
            object.textmessage = $root.WrapperMessage.TextMessage.toObject(message.textmessage, options);
            if (options.oneofs)
                object._textmessage = "textmessage";
        }
        if (message.idmessage != null && message.hasOwnProperty("idmessage")) {
            object.idmessage = $root.WrapperMessage.IdEntity.toObject(message.idmessage, options);
            if (options.oneofs)
                object._idmessage = "idmessage";
        }
        return object;
    };

    /**
     * Converts this WrapperMessage to JSON.
     * @function toJSON
     * @memberof WrapperMessage
     * @instance
     * @returns {Object.<string,*>} JSON object
     */
    WrapperMessage.prototype.toJSON = function toJSON() {
        return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
    };

    /**
     * Gets the default type url for WrapperMessage
     * @function getTypeUrl
     * @memberof WrapperMessage
     * @static
     * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
     * @returns {string} The default type url
     */
    WrapperMessage.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
        if (typeUrlPrefix === undefined) {
            typeUrlPrefix = "type.googleapis.com";
        }
        return typeUrlPrefix + "/WrapperMessage";
    };

    /**
     * MessageType enum.
     * @name WrapperMessage.MessageType
     * @enum {number}
     * @property {number} HEARTBEAT=0 HEARTBEAT value
     * @property {number} TEXTMESSAGE=1 TEXTMESSAGE value
     * @property {number} IDENTITY=2 IDENTITY value
     */
    WrapperMessage.MessageType = (function() {
        var valuesById = {}, values = Object.create(valuesById);
        values[valuesById[0] = "HEARTBEAT"] = 0;
        values[valuesById[1] = "TEXTMESSAGE"] = 1;
        values[valuesById[2] = "IDENTITY"] = 2;
        return values;
    })();

    WrapperMessage.Heartbeat = (function() {

        /**
         * Properties of a Heartbeat.
         * @memberof WrapperMessage
         * @interface IHeartbeat
         * @property {string} type Heartbeat type
         * @property {number|Long} timestamp Heartbeat timestamp
         */

        /**
         * Constructs a new Heartbeat.
         * @memberof WrapperMessage
         * @classdesc Represents a Heartbeat.
         * @implements IHeartbeat
         * @constructor
         * @param {WrapperMessage.IHeartbeat=} [properties] Properties to set
         */
        function Heartbeat(properties) {
            if (properties)
                for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
                    if (properties[keys[i]] != null)
                        this[keys[i]] = properties[keys[i]];
        }

        /**
         * Heartbeat type.
         * @member {string} type
         * @memberof WrapperMessage.Heartbeat
         * @instance
         */
        Heartbeat.prototype.type = "";

        /**
         * Heartbeat timestamp.
         * @member {number|Long} timestamp
         * @memberof WrapperMessage.Heartbeat
         * @instance
         */
        Heartbeat.prototype.timestamp = $util.Long ? $util.Long.fromBits(0,0,false) : 0;

        /**
         * Creates a new Heartbeat instance using the specified properties.
         * @function create
         * @memberof WrapperMessage.Heartbeat
         * @static
         * @param {WrapperMessage.IHeartbeat=} [properties] Properties to set
         * @returns {WrapperMessage.Heartbeat} Heartbeat instance
         */
        Heartbeat.create = function create(properties) {
            return new Heartbeat(properties);
        };

        /**
         * Encodes the specified Heartbeat message. Does not implicitly {@link WrapperMessage.Heartbeat.verify|verify} messages.
         * @function encode
         * @memberof WrapperMessage.Heartbeat
         * @static
         * @param {WrapperMessage.IHeartbeat} message Heartbeat message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        Heartbeat.encode = function encode(message, writer) {
            if (!writer)
                writer = $Writer.create();
            writer.uint32(/* id 1, wireType 2 =*/10).string(message.type);
            writer.uint32(/* id 2, wireType 0 =*/16).int64(message.timestamp);
            return writer;
        };

        /**
         * Encodes the specified Heartbeat message, length delimited. Does not implicitly {@link WrapperMessage.Heartbeat.verify|verify} messages.
         * @function encodeDelimited
         * @memberof WrapperMessage.Heartbeat
         * @static
         * @param {WrapperMessage.IHeartbeat} message Heartbeat message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        Heartbeat.encodeDelimited = function encodeDelimited(message, writer) {
            return this.encode(message, writer).ldelim();
        };

        /**
         * Decodes a Heartbeat message from the specified reader or buffer.
         * @function decode
         * @memberof WrapperMessage.Heartbeat
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @param {number} [length] Message length if known beforehand
         * @returns {WrapperMessage.Heartbeat} Heartbeat
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        Heartbeat.decode = function decode(reader, length) {
            if (!(reader instanceof $Reader))
                reader = $Reader.create(reader);
            var end = length === undefined ? reader.len : reader.pos + length, message = new $root.WrapperMessage.Heartbeat();
            while (reader.pos < end) {
                var tag = reader.uint32();
                switch (tag >>> 3) {
                case 1: {
                        message.type = reader.string();
                        break;
                    }
                case 2: {
                        message.timestamp = reader.int64();
                        break;
                    }
                default:
                    reader.skipType(tag & 7);
                    break;
                }
            }
            if (!message.hasOwnProperty("type"))
                throw $util.ProtocolError("missing required 'type'", { instance: message });
            if (!message.hasOwnProperty("timestamp"))
                throw $util.ProtocolError("missing required 'timestamp'", { instance: message });
            return message;
        };

        /**
         * Decodes a Heartbeat message from the specified reader or buffer, length delimited.
         * @function decodeDelimited
         * @memberof WrapperMessage.Heartbeat
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @returns {WrapperMessage.Heartbeat} Heartbeat
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        Heartbeat.decodeDelimited = function decodeDelimited(reader) {
            if (!(reader instanceof $Reader))
                reader = new $Reader(reader);
            return this.decode(reader, reader.uint32());
        };

        /**
         * Verifies a Heartbeat message.
         * @function verify
         * @memberof WrapperMessage.Heartbeat
         * @static
         * @param {Object.<string,*>} message Plain object to verify
         * @returns {string|null} `null` if valid, otherwise the reason why it is not
         */
        Heartbeat.verify = function verify(message) {
            if (typeof message !== "object" || message === null)
                return "object expected";
            if (!$util.isString(message.type))
                return "type: string expected";
            if (!$util.isInteger(message.timestamp) && !(message.timestamp && $util.isInteger(message.timestamp.low) && $util.isInteger(message.timestamp.high)))
                return "timestamp: integer|Long expected";
            return null;
        };

        /**
         * Creates a Heartbeat message from a plain object. Also converts values to their respective internal types.
         * @function fromObject
         * @memberof WrapperMessage.Heartbeat
         * @static
         * @param {Object.<string,*>} object Plain object
         * @returns {WrapperMessage.Heartbeat} Heartbeat
         */
        Heartbeat.fromObject = function fromObject(object) {
            if (object instanceof $root.WrapperMessage.Heartbeat)
                return object;
            var message = new $root.WrapperMessage.Heartbeat();
            if (object.type != null)
                message.type = String(object.type);
            if (object.timestamp != null)
                if ($util.Long)
                    (message.timestamp = $util.Long.fromValue(object.timestamp)).unsigned = false;
                else if (typeof object.timestamp === "string")
                    message.timestamp = parseInt(object.timestamp, 10);
                else if (typeof object.timestamp === "number")
                    message.timestamp = object.timestamp;
                else if (typeof object.timestamp === "object")
                    message.timestamp = new $util.LongBits(object.timestamp.low >>> 0, object.timestamp.high >>> 0).toNumber();
            return message;
        };

        /**
         * Creates a plain object from a Heartbeat message. Also converts values to other types if specified.
         * @function toObject
         * @memberof WrapperMessage.Heartbeat
         * @static
         * @param {WrapperMessage.Heartbeat} message Heartbeat
         * @param {$protobuf.IConversionOptions} [options] Conversion options
         * @returns {Object.<string,*>} Plain object
         */
        Heartbeat.toObject = function toObject(message, options) {
            if (!options)
                options = {};
            var object = {};
            if (options.defaults) {
                object.type = "";
                if ($util.Long) {
                    var long = new $util.Long(0, 0, false);
                    object.timestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
                } else
                    object.timestamp = options.longs === String ? "0" : 0;
            }
            if (message.type != null && message.hasOwnProperty("type"))
                object.type = message.type;
            if (message.timestamp != null && message.hasOwnProperty("timestamp"))
                if (typeof message.timestamp === "number")
                    object.timestamp = options.longs === String ? String(message.timestamp) : message.timestamp;
                else
                    object.timestamp = options.longs === String ? $util.Long.prototype.toString.call(message.timestamp) : options.longs === Number ? new $util.LongBits(message.timestamp.low >>> 0, message.timestamp.high >>> 0).toNumber() : message.timestamp;
            return object;
        };

        /**
         * Converts this Heartbeat to JSON.
         * @function toJSON
         * @memberof WrapperMessage.Heartbeat
         * @instance
         * @returns {Object.<string,*>} JSON object
         */
        Heartbeat.prototype.toJSON = function toJSON() {
            return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
        };

        /**
         * Gets the default type url for Heartbeat
         * @function getTypeUrl
         * @memberof WrapperMessage.Heartbeat
         * @static
         * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
         * @returns {string} The default type url
         */
        Heartbeat.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
            if (typeUrlPrefix === undefined) {
                typeUrlPrefix = "type.googleapis.com";
            }
            return typeUrlPrefix + "/WrapperMessage.Heartbeat";
        };

        return Heartbeat;
    })();

    WrapperMessage.TextMessage = (function() {

        /**
         * Properties of a TextMessage.
         * @memberof WrapperMessage
         * @interface ITextMessage
         * @property {string} from TextMessage from
         * @property {string} to TextMessage to
         * @property {string} content TextMessage content
         * @property {number|Long} timestamp TextMessage timestamp
         */

        /**
         * Constructs a new TextMessage.
         * @memberof WrapperMessage
         * @classdesc Represents a TextMessage.
         * @implements ITextMessage
         * @constructor
         * @param {WrapperMessage.ITextMessage=} [properties] Properties to set
         */
        function TextMessage(properties) {
            if (properties)
                for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
                    if (properties[keys[i]] != null)
                        this[keys[i]] = properties[keys[i]];
        }

        /**
         * TextMessage from.
         * @member {string} from
         * @memberof WrapperMessage.TextMessage
         * @instance
         */
        TextMessage.prototype.from = "";

        /**
         * TextMessage to.
         * @member {string} to
         * @memberof WrapperMessage.TextMessage
         * @instance
         */
        TextMessage.prototype.to = "";

        /**
         * TextMessage content.
         * @member {string} content
         * @memberof WrapperMessage.TextMessage
         * @instance
         */
        TextMessage.prototype.content = "";

        /**
         * TextMessage timestamp.
         * @member {number|Long} timestamp
         * @memberof WrapperMessage.TextMessage
         * @instance
         */
        TextMessage.prototype.timestamp = $util.Long ? $util.Long.fromBits(0,0,false) : 0;

        /**
         * Creates a new TextMessage instance using the specified properties.
         * @function create
         * @memberof WrapperMessage.TextMessage
         * @static
         * @param {WrapperMessage.ITextMessage=} [properties] Properties to set
         * @returns {WrapperMessage.TextMessage} TextMessage instance
         */
        TextMessage.create = function create(properties) {
            return new TextMessage(properties);
        };

        /**
         * Encodes the specified TextMessage message. Does not implicitly {@link WrapperMessage.TextMessage.verify|verify} messages.
         * @function encode
         * @memberof WrapperMessage.TextMessage
         * @static
         * @param {WrapperMessage.ITextMessage} message TextMessage message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        TextMessage.encode = function encode(message, writer) {
            if (!writer)
                writer = $Writer.create();
            writer.uint32(/* id 1, wireType 2 =*/10).string(message.from);
            writer.uint32(/* id 2, wireType 2 =*/18).string(message.to);
            writer.uint32(/* id 3, wireType 2 =*/26).string(message.content);
            writer.uint32(/* id 4, wireType 0 =*/32).int64(message.timestamp);
            return writer;
        };

        /**
         * Encodes the specified TextMessage message, length delimited. Does not implicitly {@link WrapperMessage.TextMessage.verify|verify} messages.
         * @function encodeDelimited
         * @memberof WrapperMessage.TextMessage
         * @static
         * @param {WrapperMessage.ITextMessage} message TextMessage message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        TextMessage.encodeDelimited = function encodeDelimited(message, writer) {
            return this.encode(message, writer).ldelim();
        };

        /**
         * Decodes a TextMessage message from the specified reader or buffer.
         * @function decode
         * @memberof WrapperMessage.TextMessage
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @param {number} [length] Message length if known beforehand
         * @returns {WrapperMessage.TextMessage} TextMessage
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        TextMessage.decode = function decode(reader, length) {
            if (!(reader instanceof $Reader))
                reader = $Reader.create(reader);
            var end = length === undefined ? reader.len : reader.pos + length, message = new $root.WrapperMessage.TextMessage();
            while (reader.pos < end) {
                var tag = reader.uint32();
                switch (tag >>> 3) {
                case 1: {
                        message.from = reader.string();
                        break;
                    }
                case 2: {
                        message.to = reader.string();
                        break;
                    }
                case 3: {
                        message.content = reader.string();
                        break;
                    }
                case 4: {
                        message.timestamp = reader.int64();
                        break;
                    }
                default:
                    reader.skipType(tag & 7);
                    break;
                }
            }
            if (!message.hasOwnProperty("from"))
                throw $util.ProtocolError("missing required 'from'", { instance: message });
            if (!message.hasOwnProperty("to"))
                throw $util.ProtocolError("missing required 'to'", { instance: message });
            if (!message.hasOwnProperty("content"))
                throw $util.ProtocolError("missing required 'content'", { instance: message });
            if (!message.hasOwnProperty("timestamp"))
                throw $util.ProtocolError("missing required 'timestamp'", { instance: message });
            return message;
        };

        /**
         * Decodes a TextMessage message from the specified reader or buffer, length delimited.
         * @function decodeDelimited
         * @memberof WrapperMessage.TextMessage
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @returns {WrapperMessage.TextMessage} TextMessage
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        TextMessage.decodeDelimited = function decodeDelimited(reader) {
            if (!(reader instanceof $Reader))
                reader = new $Reader(reader);
            return this.decode(reader, reader.uint32());
        };

        /**
         * Verifies a TextMessage message.
         * @function verify
         * @memberof WrapperMessage.TextMessage
         * @static
         * @param {Object.<string,*>} message Plain object to verify
         * @returns {string|null} `null` if valid, otherwise the reason why it is not
         */
        TextMessage.verify = function verify(message) {
            if (typeof message !== "object" || message === null)
                return "object expected";
            if (!$util.isString(message.from))
                return "from: string expected";
            if (!$util.isString(message.to))
                return "to: string expected";
            if (!$util.isString(message.content))
                return "content: string expected";
            if (!$util.isInteger(message.timestamp) && !(message.timestamp && $util.isInteger(message.timestamp.low) && $util.isInteger(message.timestamp.high)))
                return "timestamp: integer|Long expected";
            return null;
        };

        /**
         * Creates a TextMessage message from a plain object. Also converts values to their respective internal types.
         * @function fromObject
         * @memberof WrapperMessage.TextMessage
         * @static
         * @param {Object.<string,*>} object Plain object
         * @returns {WrapperMessage.TextMessage} TextMessage
         */
        TextMessage.fromObject = function fromObject(object) {
            if (object instanceof $root.WrapperMessage.TextMessage)
                return object;
            var message = new $root.WrapperMessage.TextMessage();
            if (object.from != null)
                message.from = String(object.from);
            if (object.to != null)
                message.to = String(object.to);
            if (object.content != null)
                message.content = String(object.content);
            if (object.timestamp != null)
                if ($util.Long)
                    (message.timestamp = $util.Long.fromValue(object.timestamp)).unsigned = false;
                else if (typeof object.timestamp === "string")
                    message.timestamp = parseInt(object.timestamp, 10);
                else if (typeof object.timestamp === "number")
                    message.timestamp = object.timestamp;
                else if (typeof object.timestamp === "object")
                    message.timestamp = new $util.LongBits(object.timestamp.low >>> 0, object.timestamp.high >>> 0).toNumber();
            return message;
        };

        /**
         * Creates a plain object from a TextMessage message. Also converts values to other types if specified.
         * @function toObject
         * @memberof WrapperMessage.TextMessage
         * @static
         * @param {WrapperMessage.TextMessage} message TextMessage
         * @param {$protobuf.IConversionOptions} [options] Conversion options
         * @returns {Object.<string,*>} Plain object
         */
        TextMessage.toObject = function toObject(message, options) {
            if (!options)
                options = {};
            var object = {};
            if (options.defaults) {
                object.from = "";
                object.to = "";
                object.content = "";
                if ($util.Long) {
                    var long = new $util.Long(0, 0, false);
                    object.timestamp = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
                } else
                    object.timestamp = options.longs === String ? "0" : 0;
            }
            if (message.from != null && message.hasOwnProperty("from"))
                object.from = message.from;
            if (message.to != null && message.hasOwnProperty("to"))
                object.to = message.to;
            if (message.content != null && message.hasOwnProperty("content"))
                object.content = message.content;
            if (message.timestamp != null && message.hasOwnProperty("timestamp"))
                if (typeof message.timestamp === "number")
                    object.timestamp = options.longs === String ? String(message.timestamp) : message.timestamp;
                else
                    object.timestamp = options.longs === String ? $util.Long.prototype.toString.call(message.timestamp) : options.longs === Number ? new $util.LongBits(message.timestamp.low >>> 0, message.timestamp.high >>> 0).toNumber() : message.timestamp;
            return object;
        };

        /**
         * Converts this TextMessage to JSON.
         * @function toJSON
         * @memberof WrapperMessage.TextMessage
         * @instance
         * @returns {Object.<string,*>} JSON object
         */
        TextMessage.prototype.toJSON = function toJSON() {
            return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
        };

        /**
         * Gets the default type url for TextMessage
         * @function getTypeUrl
         * @memberof WrapperMessage.TextMessage
         * @static
         * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
         * @returns {string} The default type url
         */
        TextMessage.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
            if (typeUrlPrefix === undefined) {
                typeUrlPrefix = "type.googleapis.com";
            }
            return typeUrlPrefix + "/WrapperMessage.TextMessage";
        };

        return TextMessage;
    })();

    WrapperMessage.IdEntity = (function() {

        /**
         * Properties of an IdEntity.
         * @memberof WrapperMessage
         * @interface IIdEntity
         * @property {string} userid IdEntity userid
         * @property {string} username IdEntity username
         */

        /**
         * Constructs a new IdEntity.
         * @memberof WrapperMessage
         * @classdesc Represents an IdEntity.
         * @implements IIdEntity
         * @constructor
         * @param {WrapperMessage.IIdEntity=} [properties] Properties to set
         */
        function IdEntity(properties) {
            if (properties)
                for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
                    if (properties[keys[i]] != null)
                        this[keys[i]] = properties[keys[i]];
        }

        /**
         * IdEntity userid.
         * @member {string} userid
         * @memberof WrapperMessage.IdEntity
         * @instance
         */
        IdEntity.prototype.userid = "";

        /**
         * IdEntity username.
         * @member {string} username
         * @memberof WrapperMessage.IdEntity
         * @instance
         */
        IdEntity.prototype.username = "";

        /**
         * Creates a new IdEntity instance using the specified properties.
         * @function create
         * @memberof WrapperMessage.IdEntity
         * @static
         * @param {WrapperMessage.IIdEntity=} [properties] Properties to set
         * @returns {WrapperMessage.IdEntity} IdEntity instance
         */
        IdEntity.create = function create(properties) {
            return new IdEntity(properties);
        };

        /**
         * Encodes the specified IdEntity message. Does not implicitly {@link WrapperMessage.IdEntity.verify|verify} messages.
         * @function encode
         * @memberof WrapperMessage.IdEntity
         * @static
         * @param {WrapperMessage.IIdEntity} message IdEntity message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        IdEntity.encode = function encode(message, writer) {
            if (!writer)
                writer = $Writer.create();
            writer.uint32(/* id 1, wireType 2 =*/10).string(message.userid);
            writer.uint32(/* id 2, wireType 2 =*/18).string(message.username);
            return writer;
        };

        /**
         * Encodes the specified IdEntity message, length delimited. Does not implicitly {@link WrapperMessage.IdEntity.verify|verify} messages.
         * @function encodeDelimited
         * @memberof WrapperMessage.IdEntity
         * @static
         * @param {WrapperMessage.IIdEntity} message IdEntity message or plain object to encode
         * @param {$protobuf.Writer} [writer] Writer to encode to
         * @returns {$protobuf.Writer} Writer
         */
        IdEntity.encodeDelimited = function encodeDelimited(message, writer) {
            return this.encode(message, writer).ldelim();
        };

        /**
         * Decodes an IdEntity message from the specified reader or buffer.
         * @function decode
         * @memberof WrapperMessage.IdEntity
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @param {number} [length] Message length if known beforehand
         * @returns {WrapperMessage.IdEntity} IdEntity
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        IdEntity.decode = function decode(reader, length) {
            if (!(reader instanceof $Reader))
                reader = $Reader.create(reader);
            var end = length === undefined ? reader.len : reader.pos + length, message = new $root.WrapperMessage.IdEntity();
            while (reader.pos < end) {
                var tag = reader.uint32();
                switch (tag >>> 3) {
                case 1: {
                        message.userid = reader.string();
                        break;
                    }
                case 2: {
                        message.username = reader.string();
                        break;
                    }
                default:
                    reader.skipType(tag & 7);
                    break;
                }
            }
            if (!message.hasOwnProperty("userid"))
                throw $util.ProtocolError("missing required 'userid'", { instance: message });
            if (!message.hasOwnProperty("username"))
                throw $util.ProtocolError("missing required 'username'", { instance: message });
            return message;
        };

        /**
         * Decodes an IdEntity message from the specified reader or buffer, length delimited.
         * @function decodeDelimited
         * @memberof WrapperMessage.IdEntity
         * @static
         * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
         * @returns {WrapperMessage.IdEntity} IdEntity
         * @throws {Error} If the payload is not a reader or valid buffer
         * @throws {$protobuf.util.ProtocolError} If required fields are missing
         */
        IdEntity.decodeDelimited = function decodeDelimited(reader) {
            if (!(reader instanceof $Reader))
                reader = new $Reader(reader);
            return this.decode(reader, reader.uint32());
        };

        /**
         * Verifies an IdEntity message.
         * @function verify
         * @memberof WrapperMessage.IdEntity
         * @static
         * @param {Object.<string,*>} message Plain object to verify
         * @returns {string|null} `null` if valid, otherwise the reason why it is not
         */
        IdEntity.verify = function verify(message) {
            if (typeof message !== "object" || message === null)
                return "object expected";
            if (!$util.isString(message.userid))
                return "userid: string expected";
            if (!$util.isString(message.username))
                return "username: string expected";
            return null;
        };

        /**
         * Creates an IdEntity message from a plain object. Also converts values to their respective internal types.
         * @function fromObject
         * @memberof WrapperMessage.IdEntity
         * @static
         * @param {Object.<string,*>} object Plain object
         * @returns {WrapperMessage.IdEntity} IdEntity
         */
        IdEntity.fromObject = function fromObject(object) {
            if (object instanceof $root.WrapperMessage.IdEntity)
                return object;
            var message = new $root.WrapperMessage.IdEntity();
            if (object.userid != null)
                message.userid = String(object.userid);
            if (object.username != null)
                message.username = String(object.username);
            return message;
        };

        /**
         * Creates a plain object from an IdEntity message. Also converts values to other types if specified.
         * @function toObject
         * @memberof WrapperMessage.IdEntity
         * @static
         * @param {WrapperMessage.IdEntity} message IdEntity
         * @param {$protobuf.IConversionOptions} [options] Conversion options
         * @returns {Object.<string,*>} Plain object
         */
        IdEntity.toObject = function toObject(message, options) {
            if (!options)
                options = {};
            var object = {};
            if (options.defaults) {
                object.userid = "";
                object.username = "";
            }
            if (message.userid != null && message.hasOwnProperty("userid"))
                object.userid = message.userid;
            if (message.username != null && message.hasOwnProperty("username"))
                object.username = message.username;
            return object;
        };

        /**
         * Converts this IdEntity to JSON.
         * @function toJSON
         * @memberof WrapperMessage.IdEntity
         * @instance
         * @returns {Object.<string,*>} JSON object
         */
        IdEntity.prototype.toJSON = function toJSON() {
            return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
        };

        /**
         * Gets the default type url for IdEntity
         * @function getTypeUrl
         * @memberof WrapperMessage.IdEntity
         * @static
         * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
         * @returns {string} The default type url
         */
        IdEntity.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
            if (typeUrlPrefix === undefined) {
                typeUrlPrefix = "type.googleapis.com";
            }
            return typeUrlPrefix + "/WrapperMessage.IdEntity";
        };

        return IdEntity;
    })();

    return WrapperMessage;
})();

// module.exports = $root;
export default $root;
